package com.gofaraway.common.exception.v2;

/**
 * @author ChenPeng
 * @Date 2024/7/24 16:33
 */
public class BusinessException extends BaseException {
    private static final long serialVersionUID = -1442813953383775778L;
    private static final String CODE_PREFIX = "Biz.";

    public BusinessException(BaseErrorInfo baseErrorInfo) {
        super(baseErrorInfo);
    }

    public BusinessException(BaseErrorInfo baseErrorInfo, Throwable cause) {
        super(baseErrorInfo, cause);
    }

    public BusinessException(String errorCode, String errorMessage, Throwable cause) {
        super(new BaseErrorInfoImpl(errorCode, errorMessage), cause);
    }

    public BusinessException(String errorCode, String errorMessage) {
        super(new BaseErrorInfoImpl(errorCode, errorMessage));
    }

    public static BusinessException of(BaseErrorInfo baseErrorInfo) {
        return new BusinessException(baseErrorInfo);
    }

    public static BusinessException of(String errorCode, String errorMessage) {
        return new BusinessException(errorCode, errorMessage);
    }

    public static BusinessException of(String errorCode, String errorMessage, Throwable cause) {
        return new BusinessException(errorCode, errorMessage, cause);
    }

    public static BusinessException of(CommonErrorConstants commonErrorConstants) {
        return of(commonErrorConstants.getErrorInfo());
    }

    public static BusinessException of(CommonErrorConstants commonErrorConstants, Throwable cause) {
        return new BusinessException(commonErrorConstants.getErrorInfo(), cause);
    }
}
